package router

import (
	"github.com/e421083458/golang_common/lib"
	"github.com/gin-gonic/gin"
	"time"
)

//路由初始化 可以传递全局的中间件
func InitRouter(middlewares ...gin.HandlerFunc) *gin.Engine{

	router:=gin.Default()
	router.Use(middlewares...)
	//检查服务器响应是否异常
	router.GET("/ping", func(this *gin.Context) {
		this.JSON(200,gin.H{
			"message":"pong",
			"time":time.Now().Format("2006/1/1 15:04:05"),
			"ip":lib.GetLocalIPs(),
		})
	})





	return router
}